package com.feihong.txgw.ui.fragment.home;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.webkit.JavascriptInterface;

import com.blankj.utilcode.util.LogUtils;
import com.just.agentweb.AgentWeb;

/**
 * Created by PVer on 2017/8/16.
 */

public class DiscoverInterface {
    private AgentWeb agent;
    private Context context;
    private DiscoverFragment.ActionCallBack callBack;

    public DiscoverInterface(AgentWeb agent, Context context, DiscoverFragment.ActionCallBack callBack) {
        this.agent = agent;
        this.context = context;
        this.callBack = callBack;
    }

    private Handler deliver = new Handler(Looper.getMainLooper());

    //客户服务
    @JavascriptInterface
    public void gotoService() {
        LogUtils.i("-------客户服务------");
        deliver.post(new Runnable() {
            @Override
            public void run() {
                callBack.serviceHelper();
            }
        });
    }

    //余量查询
    @JavascriptInterface
    public void gotoResidue() {
        LogUtils.i("-------余量查询------");
        deliver.post(new Runnable() {
            @Override
            public void run() {
                callBack.selectResidue();
            }
        });
    }


    //分期购
    @JavascriptInterface
    public void goto_Detail(final String  detail) {

        deliver.post(new Runnable() {
            @Override
            public void run() {
                if(detail != null){
                    callBack.goto_Detail(detail);
                }
            }
        });
    }
}
